# coding=utf-8
# 全世界最帅的帅哥
import json
from flask_restful import Resource
from ..subject_views.label_views import get_label, add_label, update_label, delete_label, query_label_by_category_id


class LabelResource(Resource):
    """
    刷题标签资源类
    """

    def get(self, action=None, label_id=None):
        """
        根据categoryId去查询标签信息
        :return:
        """
        if action == "queryByCategoryId":
            return query_label_by_category_id()
        elif label_id:
            return get_label(label_id)
        else:
            return {"code": 500, "success": False, "message": "服务器出错了"}

    def post(self):
        """
        增加一个标签
        :return:
        """
        return add_label()

    def put(self, label_id):
        """
        修改一个标签
        :param label_id:
        :return:
        """
        return update_label(label_id)

    def delete(self, label_id):
        """
        删除一个标签
        :param label_id:
        :return:
        """
        return delete_label(label_id)
